<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSysFormFieldsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sys_form_fields', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('form_id')->default(0)->comment('表单id');
            $table->string('title', 40)->default('')->comment('显示名称');
            $table->string('field_name', 64)->default('')->comment('数据库字段名称');
            $table->string('field_type')->default('')->comment('字段类型 radio checkbox input textarea ...');
            $table->string('props',1000)->default('')->comment('字段属性 {"required":true}');
            $table->string('validate')->default('')->comment('字段验证规则 {"type":"string","min":1,"max":20}');
            $table->string('style')->default('')->comment('字段样式属性 {"span":8}');
            $table->boolean('display')->default(1)->comment('是否显示字段');
            $table->boolean('searchable')->default(1)->comment('是否支持搜索');
            $table->integer('order')->default(1)->comment('排序 升序');
            $table->boolean('is_delete')->default(0);
            $table->integer('create_uid')->default(0);
            $table->integer('update_uid')->default(0);
            $table->bigInteger('created_at')->default(0);
            $table->bigInteger('updated_at')->default(0);
            $table->tinyInteger('action_type')->default(1)->comment('操作类型 1新增 2修改 3删除 增量使用');
            $table->index(['form_id', 'updated_at'], 'idx_formid_updatedat');
            $table->boolean('show_column')->default(1)->comment('是否显示在列表上 1是 0否');
            $table->text('search_config')->nullable()->comment('搜索表单配置');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sys_form_fields');
    }
}
